import { createRouter, createWebHistory } from 'vue-router'

const router = createRouter({
  history: createWebHistory(),
  routes: [
    {
      path: '/',
      component: () => import('@/layouts/MobileLayout.vue'),
      children: [
        {
          path: '',
          redirect: '/dashboard'
        },
        {
          path: 'dashboard',
          name: 'dashboard',
          component: () => import('@/views/dashboard/index.vue'),
          meta: {
            title: '生产监控'
          }
        },
        {
          path: 'yield',
          name: 'yield',
          component: () => import('@/views/yield/index.vue'),
          meta: {
            title: '良率分析'
          }
        },
        {
          path: 'equipment',
          name: 'equipment',
          component: () => import('@/views/equipment/index.vue'),
          meta: {
            title: '设备维护'
          }
        },
        {
          path: 'data-integration',
          name: 'data-integration',
          component: () => import('@/views/data-integration/index.vue'),
          meta: {
            title: '数据集成'
          }
        },
        {
          path: 'system',
          name: 'system',
          component: () => import('@/views/system/index.vue'),
          meta: {
            title: '系统设置'
          }
        }
      ]
    }
  ]
})

// 路由守卫
router.beforeEach((to, from, next) => {
  // 设置页面标题
  document.title = to.meta.title ? `${to.meta.title} - 制造业智能分析系统` : '制造业智能分析系统'
  next()
})

export default router 